package com.cjb.cloudsystem.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjb.cloudsystem.entity.SysUserToken;
import com.cjb.cloudsystem.service.SysUserTokenService;
import com.cjb.common.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @Author 1.0.0 2023-08-29
* @Package IntelliJ IDEA
* @Class SysUserTokenControl
* @Date 2023-08-29
*/
@RestController
@Tag(name="sysUserToken")
@RequestMapping(value = {"sysUserToken"})
@ApiResponses(@ApiResponse(responseCode = "200", description = "接口请求成功"))
@Slf4j
public class SysUserTokenController {
    /*
    * 注入事物类
    */
    @Autowired
    private SysUserTokenService sysUserTokenService;

    /**
    *单个保存
    *
    * @Author 1.0.0 2023-08-29
    * @Value
    * @Title
    */
    @PostMapping("/save")
    @Operation(summary = "单个保存")

    public Result<Boolean> save(@RequestBody SysUserToken sysUserToken){
        return Result.success(sysUserTokenService.save(sysUserToken));
    }

    /**
    *批量保存
    *
    * @Author 1.0.0 2023-08-29
    * @Value
    * @Title
    */
    @PostMapping("/listSave")
    @Operation(summary = "批量保存")
    public Result <Integer> listSave(@RequestBody List<SysUserToken> sysUserToken){
        return Result.success(sysUserTokenService.listSave(sysUserToken));
    }

    /**
    *单个查询
    *
    * @Author 1.0.0 2023-08-29
    * @Value
    * @Title
    */
    @GetMapping("/queryById")
    @Operation(summary = "单个查询-通过ID")
    public Result<SysUserToken> queryById(@RequestBody SysUserToken sysUserToken){
        return Result.success( sysUserTokenService.queryById(sysUserToken));
    }

    /**
    * 分页查询
    *
    * @Author 1.0.0 2023-08-29
    * @Value
    * @Title
    */
    @GetMapping("/queryPage")
    @Operation(summary = "分页查询-通过页码")
    public Result<Page<SysUserToken>> queryPage(@RequestBody SysUserToken sysUserToken){
    Page sysUserTokenPage = new Page<SysUserToken>();
        return Result.success( sysUserTokenService.queryPage(sysUserTokenPage,sysUserToken));
    }

    /**login
    * 批量更新
    *
    * @Author 1.0.0 2023-08-29
    * @Value
    * @Title
    */
    @PostMapping("/listUpdate")
    @Operation(summary = "批量更新")
    public Result <String> listUpdate(@RequestBody List<SysUserToken> sysUserToken){
        sysUserTokenService.listUpdate(sysUserToken);
        return Result.success();
    }


    /**
    * 批量删除
    *
    * @Author 1.0.0 2023-08-29
    * @Value
    * @Title
    */
    @PostMapping("/listDelete")
    @Operation(summary = "批量删除")
    public Result <String> listDelete(@RequestBody List<SysUserToken> sysUserToken){
        sysUserTokenService.listDelete(sysUserToken);
        return Result.success();
    }
    /**
    * 通过id删除
    *
    * @Author 1.0.0 2023-08-29
    * @Value
    * @Title
    */
    @PostMapping("/deleteById")
    @Operation(summary = "单个删除-通过ID")
    public Result <String> deleteById(@RequestBody SysUserToken sysUserToken){
        sysUserTokenService.deleteById(sysUserToken);
        return Result.success();
    }

    /**
    * 返回全部信息
    *
    * @Author 1.0.0 2023-08-29
    * @Value
    * @Title
    */
    @PostMapping("/returnAllData")
    @Operation(summary = "返回所有信息")
    public Result <List<SysUserToken>> returnAllData(){
        return Result.success(sysUserTokenService.returnAllData());
    }

}
